/**
 * 功能说明:
 * 功能作者:
 * 创建日期:
 */
package com.jml.API接口幂等性.controller;

import com.jml.API接口幂等性.annation.ExtApiIdempotent;
import com.jml.API接口幂等性.annation.ExtApiToken;
import com.jml.API接口幂等性.entity.OrderEntity;
import com.jml.API接口幂等性.utils.ConstantUtils;
import com.jml.API接口幂等性.utils.RedisToken;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
public class OrderController {

	@Autowired
	private RedisToken redisToken;

	@RequestMapping("/redisToken")
	@ExtApiToken
	public String RedisToken(){
		return "/custinfoform";
	}

	//redis线程是安全的，可以不加synchonized
	@RequestMapping(value = "/addOrderExtApiIdempotent", produces = "application/json; charset=utf-8")
	@ExtApiIdempotent(type = ConstantUtils.EXTAPIHEAD)
	public String addOrderExtApiIdempotent(@RequestBody OrderEntity orderEntity, HttpServletRequest request) {
		int i=1;
		return i > 0 ? "添加成功" : "添加失败" + "";
	}

}
